using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class VersionIDAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public VersionIDAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"2.0","2.0D","2.1","2.2","2.3"};
						validVersionCodes[HL7Version.v231] = new string[]{"2.0","2.0D","2.1","2.2","2.3","2.3.1","2.3.2"};
						validVersionCodes[HL7Version.v24] = new string[]{"2.0","2.0D","2.1","2.2","2.3","2.3.1","2.4"};
						validVersionCodes[HL7Version.v25] = new string[]{"2.0","2.0D","2.1","2.2","2.3","2.3.1","2.4","2.5"};
						validVersionCodes[HL7Version.v251] = new string[]{"2.0","2.0D","2.1","2.2","2.3","2.3.1","2.4","2.5","2.5.1"};
						validVersionCodes[HL7Version.v26] = new string[]{"2.0","2.0D","2.1","2.2","2.3","2.3.1","2.4","2.5","2.5.1","2.6"};
						validVersionCodes[HL7Version.v27] = new string[]{"2.0","2.0D","2.1","2.2","2.3","2.3.1","2.4","2.5","2.5.1","2.6","2.7"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"Release 2.0  September 1988","Demo 2.0  October 1988","Release 2.1  March 1990","Release 2.2  December 1994","Release 2.3 ?? 1996"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Release 2.0","Demo 2.0","Release 2. 1","Release 2.2","Release 2.3","Release 2.3.1","Release 2.3.2"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Release 2.0","Demo 2.0","Release 2. 1","Release 2.2","Release 2.3","Release 2.3.1","Release 2.4"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Release 2.0","Demo 2.0","Release 2. 1","Release 2.2","Release 2.3","Release 2.3.1","Release 2.4","Release 2.5"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Release 2.0","Demo 2.0","Release 2. 1","Release 2.2","Release 2.3","Release 2.3.1","Release 2.4","Release 2.5","Release 2.5.1"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Release 2.0","Demo 2.0","Release 2. 1","Release 2.2","Release 2.3","Release 2.3.1","Release 2.4","Release 2.5","Release 1.5.1","Release 2.6"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Release 2.0","Demo 2.0","Release 2.1","Release 2.2","Release 2.3","Release 2.3.1","Release 2.4","Release 2.5","Release 2.5.1","Release 2.6","Release 2.7"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
